#!/usr/bin/env python
# -*- coding:utf-8 -*-
# @Time: 2022/9/16 1:35
# @Author: 王思淇
# @Email: xxx@gmail.com
# @File：add_user_page.py

from selenium.webdriver.common.by import By
from pages.base_page import BasePage
from config.config import HOST
from selenium.webdriver.support.select import Select


class AddUserPage(BasePage):
    """添加用户页面类"""


    user_name_locator = (
    By.XPATH, '/html/body/div[5]/div[2]/div/div[2]/div[2]/form/table/tbody/tr[1]/td[2]/input')  # 用户名
    user_pass_locator = (By.XPATH, '//*[@id="password"]')  # 密码
    user_type_locator = (
    By.XPATH, '/html/body/div[5]/div[2]/div/div[2]/div[2]/form/table/tbody/tr[3]/td[2]/select')  # 用户类型
    department_locator = (
    By.XPATH, '/html/body/div[5]/div[2]/div/div[2]/div[2]/form/table/tbody/tr[4]/td[2]/select')  # 部门
    # 添加
    add_locator = (By.XPATH, '/html/body/div[5]/div[2]/div/div[2]/div[2]/form/table/tbody/tr[6]/td[2]/input[1]')

    def input_user_name(self):
        self.driver.find_element(*self.user_name_locator).send_keys()

    def input_user_pass(self):
        self.driver.find_element(*self.user_name_locator).send_keys()
    def user_type_by__visible_text(self):
        select = self.driver.find_element(*self.user_type_locator)
        Select(select).select_by_visible_text()
    def department_by__visible_text(self):
        select = self.driver.find_element(*self.department_locator)
        Select(select).select_by_visible_text()
    def click_add(self):
        self.driver.find_element(*self.add_locator).click()

